<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="az" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>首页-框架页</title>

    <%@include file="/view/common/common-href.jsp" %>

    <style>

    </style>

</head>

<body>

<div class="form-box" style="padding-top:15px;">
    <div class="form-body">
        <form name="azeroth_form" id="azeroth_form" class="form form-horizontal"
              method="post" url="/sys/role/accredit?_m=exec">
            <input type="hidden" name="powrUids" id="powrUids" />
            <input type="hidden" name="roleUid" id="roleUid" value="${roleUid}" />

            <ul id="tt" class="easyui-tree"
                data-options="
                    method:'post',
                    url:'/sys/role/accredit?_m=tree&roleUid=${roleUid}',
                    animate:false,checkbox:true,
                    onLoadSuccess:collapseAll
                "></ul>
        </form>
    </div>
</div>

</body>

</html>
<script type="text/javascript">
    var $objData = {};
    var $azerothForm = $('#azeroth_form');

    function collapseAll() {
        $("#tt").tree("collapseAll");
    }

    $objData.submitForm = function(dialog, gird) {

        $azerothForm.submit();

        // 返回成功后，销毁弹出框、刷新列表
        $objData.sucess = function() { gird.datagrid('reload'); dialog.dialog('destroy'); }

    };

    $azerothForm.form({
        url: $azerothForm.attr("url"),
        onSubmit:function(){
            var objs = $("#tt").tree('getChecked', ['checked']); //,'indeterminate'
            var powrUids = "";
            for(var i=0; i<objs.length; i++) {
                powrUids += objs[i].id + ",";
            }
            $("#powrUids").val(powrUids.substring(0, powrUids.length-1));

            if($(this).form('enableValidation').form('validate')){
                parent.$.messager.progress({ text : '正在处理，请稍后...' });
                return true;
            }else{
                return false;
            }
        },
        success:function(data) {
            parent.$.messager.alert("提示","保存成功！","info",function(){
                $objData.sucess();
            });
            parent.$.messager.progress('close');
        },
        error:function(){
            parent.$.messager.progress('close');
        }
    });

</script>